const router = require('koa-router')()
const {
  getList,
  getDetail,
} = require('../controller/product')
const { SuccessModel, ErrorModel } = require('../model/resModel')

router.prefix('/api/product')


router.get('/list',async function (ctx, next) {
    const keyword = ctx.query.keyword || ''
    const listData = await getList(keyword)
    ctx.body = new SuccessModel(listData)
})

router.get('/detail',async function (ctx, next) {
    const data = await getDetail(ctx.query.id)
    ctx.body = new SuccessModel(data)
})

module.exports = router
